<html>
<head>
	<meta charset='utf-8' />

	<title>便民信息</title>
	<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />
	<style>
		@media screen and (max-width:450px){
			#nav_bottom{width:98%;margin:0 auto}
			#content{width:98%;margin:0 auto}
			/*页面宽度900以下时 .abc的宽度为450*/
		}
		@media screen and (min-width:450px){
			#nav_bottom{width:450px;margin:0 auto}
			#content{width:450px;margin:0 auto}
			/*页面宽度900以下时 .abc的宽度为450*/
		}
	</style>
</head>
<body style='padding:0;margin:0;background:#eee'>
	<!--主内容区-->
	<div style='margin-bottom:50px' id='content'>
	
		<!--顶部广告区-->
		<div style='margin-bottom:5px;height:70px;border:1px solid'>
			顶部广告区
		</div>
	


		<!--顶部搜索区-->
		<div style='margin-bottom:5px;height:35px;display:flex'>
			<div style='flex:2;height:100%;border:0px solid;'>
				<select style='width:100%;height:100%;appearance:none;-moz-appearance:none;-webkit-appearance:none;background:#eee' id='service_index_search_select'>
					<option value='none'>条件选择</option>
					<option value='title'>按标题</option>
					<option value='content'>按内容</option>
				</select>
			</div>
			<div style='flex:5;height:100%;border:0px solid'>
				<input name='service_index_search_input' style='width:100%;height:100%' />
			</div>
			<div style='flex:2;height:100%;border:0px solid'>
				<button type='button' style='width:100%;height:100%' id='service_index_search_button' >搜索</button>
			</div>
		</div>
		
		<!--分类及条件-->
		<div style='margin-bottom:5px'>
			<!--服务选择-->
			<div id='service_index_conditionArea' style='border:1px solid red'></div>

			<!--服务下分类条件-->
			<div id='service_index_conditionArea_sub'></div>
			<div style='clear:both'></div>
		</div>
		
		
		
		<!--主体内容-->
		<div style='margin-bottom:80px' id='service_index_infos'>

		</div>


	</div>


</body>
</html>
<!--script src='./Public/Js/jquery.js'></script-->
<script src='http://apps.bdimg.com/libs/jquery/1.6.4/jquery.min.js'></script>
<script src='./Public/Js/md5.js'></script>
<!--script src='./Service/Js/service_index.js'></script-->
<script>
$(function(){

	//页面初始化时设置城市码
	sessionStorage.city1 = 7;		
	sessionStorage.city2 = 91;
	sessionStorage.city3 = 912;



	//页面初始化时加载服务列表
	$.ajax({
		url:'Service/Template/Service_index/service_index_conditionArea.html?a='+Math.random(),
		async:false,
		success:function(res){
			$('#service_index_conditionArea').html(res);
			service_index_getCondition(); 	//加载服务下分类条件
		},
		error:function(){
			$.ajax({
				url:'interface.php',
				async:false,
				data:{
					type:'token',
				},
				success:function(token){
					$.ajax({
						url:'before.php/Before/Index/service_index_conditionArea',
						async:false,
						data:{
							token:token
						},
						success:function(res){
							$('#service_index_conditionArea').html(res);
							service_index_getCondition();	//加载服务下分类条件
						}
					});
				}
			});
		}
	});




	//搜索框文本的状态维持
	if(sessionStorage.service_index_search_input){
		$('input[name=service_index_search_input]').val(sessionStorage.service_index_search_input);
	}
	//条件选择的状态维持
	if(sessionStorage.service_index_search_select){
		$('#service_index_search_select').find('option').each(function(){
			if($(this).val() == sessionStorage.service_index_search_select){
				$(this).attr('selected',true);
			}
		});
	}
	//搜索按钮点击事件
	$("#service_index_search_button").click(function(){
		var service_index_search_input = $('input[name=service_index_search_input]').val().trim();
		if(!service_index_search_input){ //如果文本框为空，将搜索条件重置
			sessionStorage.service_index_search_input = '';
			sessionStorage.service_index_search_select = '';
		}else{
			//如果两个搜索条件没有变化，点击按钮则没有事件
			if(sessionStorage.service_index_search_select == $('#service_index_search_select').find('option:selected').val() && sessionStorage.service_index_search_input == service_index_search_input){
				exit;
			}
			//如搜索条件有变化，则缓存搜索条件 
			sessionStorage.service_index_search_select = $('#service_index_search_select').find('option:selected').val();
			sessionStorage.service_index_search_input = service_index_search_input;
		}
		clear_sess('pnow','service') //当搜索条件变化时，清空其它缓存条件
		location.reload(true); //刷新当前页面
	});


	//加载底部导航
	$.ajax({
		url:'./Public/Base/before_base_bottom_nav.html',
		success:function(res){
			$(res).appendTo('body');
		}
	})
});



//加载服务下分类条件
function service_index_getCondition(){
	if(!sessionStorage.service_index_conditionArea_serviceId){
		sessionStorage.service_index_conditionArea_serviceId = 'none';
	}
	var url ='Service/Template/Service_index/service_index_conditionArea_sub_'+sessionStorage.service_index_conditionArea_serviceId+'.html?a='+Math.random();
	$.ajax({
		url:url,
		async:false,
		success:function(res){
			$('#service_index_conditionArea_sub').html(res);
			service_index_Get_Infos();	//加载信息列表
		},
		error:function(){
			$.ajax({
				url:'interface.php',
				async:false,
				data:{
					type:'token',
				},
				success:function(token){
					$.ajax({
						url:'before.php/Before/Index/service_index_conditionArea_sub',
						async:false,
						data:{
							service_id:sessionStorage.service_index_conditionArea_serviceId,
							token:token
						},
						success:function(res){
							$('#service_index_conditionArea_sub').html(res);
							service_index_Get_Infos();	//加载信息列表
						}
					});
				}
			})
		}
	});
}












//加载数据信息列表
function service_index_Get_Infos(){
	//生成信息静静的静态文件名
	if(!sessionStorage.service_index_infors_pnow){
		sessionStorage.service_index_infors_pnow = 1;
	}
	pnow = sessionStorage.service_index_infors_pnow;
	search = sessionStorage.service_index_search_input;
	search_select = sessionStorage.service_index_search_select;
	service_id = sessionStorage.service_index_conditionArea_serviceId;
	condtype = sessionStorage.service_index_conditionArea_sub_condtype;
	condprice = sessionStorage.service_index_conditionArea_sub_condprice;
	condedu = sessionStorage.service_index_conditionArea_sub_condedu;
	condexperience = sessionStorage.service_index_conditionArea_sub_condexperience;
	condindustry = sessionStorage.service_index_conditionArea_sub_condindustry;
	condshape = sessionStorage.service_index_conditionArea_sub_condshape;
	condarea = sessionStorage.service_index_conditionArea_sub_condarea;
	condanimal = sessionStorage.service_index_conditionArea_sub_condanimal;
	condgoods = sessionStorage.service_index_conditionArea_sub_condgoods;
	condbrand = sessionStorage.service_index_conditionArea_sub_condbrand;
	condcar_type = sessionStorage.service_index_conditionArea_sub_condcar_type;
	conduse_year = sessionStorage.service_index_conditionArea_sub_conduse_year;
	//alert(conduse_year);
	var arr = ['pnow','search','search_select','service_id','condtype','condprice','condedu','condexperience','condindustry','condshape','condarea','condanimal','condgoods','condbrand','condcar_type','conduse_year'];
	var str = 'file_name:'+pnow+search+search_select+service_id+condtype+condprice+condedu+condexperience+condindustry+condshape+condarea+condanimal+condgoods+condbrand+condcar_type+conduse_year+sessionStorage.city1+sessionStorage.city2+sessionStorage.city3;
	var file_name = md5(str);

	$.ajax({
		url:'Service/Template/Service_index/'+file_name+'.html?t='+Math.random(),
		async:false,
		success:function(res,xhr,t){
			var ServerTime = new Date(t.getResponseHeader('Date')).getTime();
			var get_time = res.match(/timestamp([0-9]{13})timestamp/)[1];
			if(ServerTime > (parseInt(get_time)+10000)){
				//alert(7);
				service_index_getInfos(file_name);
			}else{
				//alert(8);
				$('#service_index_infos').html(res);
			}
		},
		error:function(res){
			//alert(9);
			service_index_getInfos(file_name);
		}
	});


}


function service_index_getInfos(file_name){

	$.ajax({
		url:'interface.php',
		async:false,
		data:{
			type:'token',
		},
		success:function(token){
			$.ajax({
				url:'before.php/Before/Index/service_index_infos',
				async:false,
				data:{
					token:token,
					city1:sessionStorage.city1,
					city2:sessionStorage.city2,
					city3:sessionStorage.city3,
					file_name:file_name,
					pnow:sessionStorage.service_index_infors_pnow,
					search:sessionStorage.service_index_search_input,
					search_select:sessionStorage.service_index_search_select,
					service_id:sessionStorage.service_index_conditionArea_serviceId,
					service_name:sessionStorage.service_index_conditionArea_serviceName,
					condtype:sessionStorage.service_index_conditionArea_sub_condtype,
					condprice:sessionStorage.service_index_conditionArea_sub_condprice,

					//招聘求职
					condedu:sessionStorage.service_index_conditionArea_sub_condedu,
					condexperience:sessionStorage.service_index_conditionArea_sub_condexperience,
					condindustry:sessionStorage.service_index_conditionArea_sub_condindustry,

					//房屋租售
					condshape:sessionStorage.service_index_conditionArea_sub_condshape,
					condarea:sessionStorage.service_index_conditionArea_sub_condarea,

					//宠物交易 
					condanimal:sessionStorage.service_index_conditionArea_sub_condanimal,

					//旧货
					condgoods:sessionStorage.service_index_conditionArea_sub_condgoods,

					//二手车
					condbrand:sessionStorage.service_index_conditionArea_sub_condbrand,
					condcar_type:sessionStorage.service_index_conditionArea_sub_condcar_type,
					conduse_year:sessionStorage.service_index_conditionArea_sub_conduse_year
				},
				success:function(res){
					$('#service_index_infos').html(res);
				}
			});
		}
	})
}



//清除sessionStorage 数据缓存
function clear_sess(pnow='',service=''){
	if(pnow){
		sessionStorage.service_index_infors_pnow = 1;
	}
	if(service){
		sessionStorage.service_index_conditionArea_serviceId = 'none';
	}

	//清除分类条件id缓存
	//通用
	sessionStorage.service_index_conditionArea_sub_condtype='none';
	sessionStorage.service_index_conditionArea_sub_condprice='none';

	//招聘求职
	sessionStorage.service_index_conditionArea_sub_condedu='none';
	sessionStorage.service_index_conditionArea_sub_condexperience='none';
	sessionStorage.service_index_conditionArea_sub_condindustry='none';

	//房屋租售
	sessionStorage.service_index_conditionArea_sub_condshape='none';
	sessionStorage.service_index_conditionArea_sub_condarea='none';

	//宠物交易 
	sessionStorage.service_index_conditionArea_sub_condanimal='none';

	//旧货
	sessionStorage.service_index_conditionArea_sub_condgoods='none';

	//二手车
	sessionStorage.service_index_conditionArea_sub_condbrand='none';
	sessionStorage.service_index_conditionArea_sub_condcar_type='none';
	sessionStorage.service_index_conditionArea_sub_conduse_year='none';
}

function login_v(){
	if(!sessionStorage.uid){
		location.href='service_login.html';exit;
	}
}

</script>












